<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>清晰账本 - 预算管理</title>
    <link rel="stylesheet" href="glassmorphism.css">
    <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            font-family: 'Arial', sans-serif;
        }
        
        body {
            background: linear-gradient(45deg, #6a11cb, #2575fc);
            min-height: 100vh;
            color: #fff;
            padding-bottom: 80px;
        }
        
        .app-container {
            max-width: 480px;
            margin: 0 auto;
            padding: 20px;
        }
        
        .header {
            display: flex;
            align-items: center;
            margin-bottom: 30px;
        }
        
        .back-button {
            width: 40px;
            height: 40px;
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            background: rgba(255, 255, 255, 0.1);
            backdrop-filter: blur(5px);
            border: 1px solid rgba(255, 255, 255, 0.2);
            margin-right: 15px;
            cursor: pointer;
        }
        
        .page-title {
            font-size: 22px;
            font-weight: bold;
        }
        
        .budget-summary {
            background: rgba(255, 255, 255, 0.1);
            backdrop-filter: blur(10px);
            border: 1px solid rgba(255, 255, 255, 0.2);
            border-radius: 20px;
            padding: 25px;
            margin-bottom: 25px;
        }
        
        .summary-title {
            font-size: 18px;
            margin-bottom: 15px;
        }
        
        .summary-row {
            display: flex;
            justify-content: space-between;
            margin-bottom: 10px;
        }
        
        .summary-label {
            opacity: 0.8;
        }
        
        .summary-value {
            font-weight: bold;
        }
        
        .section-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 15px;
        }
        
        .section-title {
            font-size: 18px;
            font-weight: bold;
        }
        
        .add-budget-btn {
            width: 40px;
            height: 40px;
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            background: rgba(255, 255, 255, 0.15);
            backdrop-filter: blur(5px);
            border: 1px solid rgba(255, 255, 255, 0.3);
            cursor: pointer;
            transition: all 0.3s;
        }
        
        .add-budget-btn:hover {
            background: rgba(255, 255, 255, 0.2);
            transform: scale(1.05);
        }
        
        .budget-list {
            margin-bottom: 30px;
        }
        
        .budget-item {
            background: rgba(255, 255, 255, 0.1);
            backdrop-filter: blur(10px);
            border: 1px solid rgba(255, 255, 255, 0.2);
            border-radius: 15px;
            padding: 20px;
            margin-bottom: 15px;
        }
        
        .budget-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 15px;
        }
        
        .budget-category {
            display: flex;
            align-items: center;
        }
        
        .category-icon {
            width: 40px;
            height: 40px;
            border-radius: 10px;
            background: rgba(255, 255, 255, 0.1);
            display: flex;
            align-items: center;
            justify-content: center;
            margin-right: 15px;
        }
        
        .category-name {
            font-size: 18px;
            font-weight: bold;
        }
        
        .budget-actions {
            display: flex;
        }
        
        .budget-edit, .budget-delete {
            width: 36px;
            height: 36px;
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            background: rgba(255, 255, 255, 0.1);
            margin-left: 10px;
            cursor: pointer;
        }
        
        .budget-delete {
            background: rgba(255, 94, 98, 0.2);
        }
        
        .budget-details {
            margin-bottom: 15px;
        }
        
        .budget-amount {
            display: flex;
            justify-content: space-between;
            margin-bottom: 5px;
        }
        
        .amount-label {
            opacity: 0.8;
        }
        
        .amount-value {
            font-weight: bold;
        }
        
        .budget-progress {
            width: 100%;
            height: 8px;
            background: rgba(255, 255, 255, 0.1);
            border-radius: 4px;
            overflow: hidden;
            margin-top: 10px;
        }
        
        .progress-bar {
            height: 100%;
            border-radius: 4px;
            transition: width 0.3s ease;
        }
        
        .progress-normal {
            background: rgba(38, 222, 129, 0.8);
        }
        
        .progress-warning {
            background: rgba(252, 211, 77, 0.8);
        }
        
        .progress-danger {
            background: rgba(255, 94, 98, 0.8);
        }
        
        .empty-state {
            text-align: center;
            padding: 40px 20px;
            background: rgba(255, 255, 255, 0.05);
            backdrop-filter: blur(5px);
            border-radius: 15px;
            margin-bottom: 25px;
        }
        
        .empty-icon {
            font-size: 48px;
            margin-bottom: 15px;
            opacity: 0.7;
        }
        
        .empty-text {
            font-size: 16px;
            opacity: 0.7;
            margin-bottom: 20px;
        }
        
        .add-first-btn {
            display: inline-block;
            padding: 12px 24px;
            background: rgba(255, 255, 255, 0.1);
            backdrop-filter: blur(5px);
            border: 1px solid rgba(255, 255, 255, 0.2);
            border-radius: 50px;
            font-size: 16px;
            cursor: pointer;
            transition: all 0.3s;
        }
        
        .add-first-btn:hover {
            background: rgba(255, 255, 255, 0.2);
            transform: translateY(-3px);
        }
        
        .modal {
            position: fixed;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background: rgba(0, 0, 0, 0.5);
            backdrop-filter: blur(5px);
            z-index: 1000;
            display: none;
            align-items: center;
            justify-content: center;
        }
        
        .modal-content {
            width: 90%;
            max-width: 320px;
            background: rgba(35, 35, 35, 0.95);
            backdrop-filter: blur(15px);
            border-radius: 15px;
            padding: 25px;
            border: 1px solid rgba(255, 255, 255, 0.1);
        }
        
        .modal-header {
            margin-bottom: 20px;
            text-align: center;
            font-size: 18px;
            font-weight: bold;
        }
        
        .form-group {
            margin-bottom: 20px;
        }
        
        .form-label {
            display: block;
            font-size: 14px;
            margin-bottom: 8px;
            opacity: 0.8;
        }
        
        .form-input {
            width: 100%;
            padding: 12px;
            border-radius: 10px;
            background: rgba(255, 255, 255, 0.1);
            border: 1px solid rgba(255, 255, 255, 0.2);
            color: white;
            font-size: 16px;
        }
        
        .category-select {
            width: 100%;
            padding: 12px;
            border-radius: 10px;
            background: rgba(255, 255, 255, 0.1);
            border: 1px solid rgba(255, 255, 255, 0.2);
            color: white;
            font-size: 16px;
            appearance: none;
        }
        
        .modal-actions {
            display: flex;
            justify-content: space-between;
        }
        
        .modal-button {
            flex: 1;
            padding: 12px;
            border-radius: 10px;
            text-align: center;
            cursor: pointer;
            font-size: 16px;
            margin: 0 5px;
        }
        
        .cancel-button {
            background: rgba(255, 255, 255, 0.1);
        }
        
        .save-button {
            background: rgba(38, 222, 129, 0.2);
        }
        
        .delete-button {
            background: rgba(255, 94, 98, 0.2);
        }
        
        .toast {
            position: fixed;
            top: 20px;
            left: 50%;
            transform: translateX(-50%);
            background: rgba(38, 222, 129, 0.2);
            backdrop-filter: blur(10px);
            border: 1px solid rgba(255, 255, 255, 0.2);
            border-radius: 10px;
            padding: 15px 20px;
            color: white;
            font-size: 14px;
            opacity: 0;
            transition: opacity 0.3s;
            z-index: 1200;
        }
        
        .toast.show {
            opacity: 1;
        }
        
        .toast.error {
            background: rgba(255, 94, 98, 0.2);
        }
        
        .navigation {
            position: fixed;
            bottom: 0;
            left: 0;
            right: 0;
            display: flex;
            justify-content: space-around;
            padding: 15px 0;
            background: rgba(255, 255, 255, 0.1);
            backdrop-filter: blur(10px);
            border-top: 1px solid rgba(255, 255, 255, 0.2);
            z-index: 100;
        }
        
        .nav-item {
            display: flex;
            flex-direction: column;
            align-items: center;
            color: rgba(255, 255, 255, 0.7);
            text-decoration: none;
            transition: color 0.3s;
        }
        
        .nav-item.active {
            color: #fff;
        }
    </style>
</head>
<body>
    <div class="app-container">
        <div class="header">
            <div class="back-button" onclick="window.location.href='my_profile.html'">
                <i class="material-icons">arrow_back</i>
            </div>
            <div class="page-title">预算管理</div>
        </div>
        
        <div class="budget-summary">
            <div class="summary-title">本月预算概览</div>
            <div class="summary-row" id="totalBudget">
                <div class="summary-label">总预算</div>
                <div class="summary-value">¥0.00</div>
            </div>
            <div class="summary-row" id="totalSpent">
                <div class="summary-label">已使用</div>
                <div class="summary-value">¥0.00</div>
            </div>
            <div class="summary-row" id="totalRemaining">
                <div class="summary-label">剩余金额</div>
                <div class="summary-value">¥0.00</div>
            </div>
        </div>
        
        <div class="section-header">
            <div class="section-title">预算列表</div>
            <div class="add-budget-btn" onclick="openAddBudgetModal()">
                <i class="material-icons">add</i>
            </div>
        </div>
        
        <div class="budget-list" id="budgetList">
            <!-- 预算列表将通过JavaScript动态填充 -->
        </div>
        
        <div class="empty-state" id="emptyState" style="display: none;">
            <div class="empty-icon">
                <i class="material-icons">account_balance</i>
            </div>
            <div class="empty-text">暂无预算，开始规划你的支出</div>
            <div class="add-first-btn" onclick="openAddBudgetModal()">
                <i class="material-icons">add</i> 添加第一个预算
            </div>
        </div>
    </div>
    
    <!-- 添加/编辑预算模态框 -->
    <div class="modal" id="budgetModal">
        <div class="modal-content">
            <div class="modal-header" id="modalTitle">添加预算</div>
            
            <div class="form-group">
                <label class="form-label">选择分类</label>
                <select class="category-select" id="categorySelect">
                    <!-- 分类选项将通过JavaScript动态填充 -->
                </select>
            </div>
            
            <div class="form-group">
                <label class="form-label">预算金额</label>
                <input type="number" class="form-input" id="budgetAmountInput" placeholder="请输入金额">
            </div>
            
            <div class="modal-actions">
                <div class="modal-button cancel-button" onclick="closeModal()">取消</div>
                <div class="modal-button save-button" id="saveBudgetBtn" onclick="saveBudget()">保存</div>
            </div>
        </div>
    </div>
    
    <!-- 删除确认模态框 -->
    <div class="modal" id="deleteModal">
        <div class="modal-content">
            <div class="modal-header">删除预算</div>
            <p style="margin-bottom: 20px; text-align: center;">确定要删除此预算吗？</p>
            
            <div class="modal-actions">
                <div class="modal-button cancel-button" onclick="closeDeleteModal()">取消</div>
                <div class="modal-button delete-button" onclick="confirmDeleteBudget()">删除</div>
            </div>
        </div>
    </div>
    
    <div class="toast" id="toast">操作成功</div>
    
    <div class="navigation">
        <a href="index.html" class="nav-item">
            <i class="material-icons">home</i>
            <span>首页</span>
        </a>
        <a href="transactions.html" class="nav-item">
            <i class="material-icons">receipt_long</i>
            <span>交易</span>
        </a>
        <a href="statistics.html" class="nav-item">
            <i class="material-icons">pie_chart</i>
            <span>统计</span>
        </a>
        <a href="my_profile.html" class="nav-item active">
            <i class="material-icons">person</i>
            <span>我的</span>
        </a>
    </div>
    
    <script src="app_data.js"></script>
    <script src="budget_script.js"></script>
</body>
</html> 